<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.lmpop.trade.ti_member.*" %>
<%@page import="java.util.*" %>
<%@page import="com.lmpop.trade.ts_custclass.*" %>
<%@ page import="com.lmpop.trade.tb_commpara.Tb_commparaInfo" %>
<%@page import="com.lmpop.frame.util.PageTools" %>
<%@page import="com.lmpop.trade.ts_area.*" %>
<%@page import="com.lmpop.trade.ti_custlevel.Ti_custlevelInfo" %>
<%
	request.setCharacterEncoding("UTF-8");
	Map ti_member = new Hashtable();
	String s_cust_name = "",user_name="";
	if(request.getParameter("s_cust_name")!=null && !request.getParameter("s_cust_name").equals("")){
		s_cust_name = request.getParameter("s_cust_name");
		ti_member.put("cust_name",s_cust_name);
	}
	if(request.getParameter("user_name")!=null && !request.getParameter("user_name").equals("")){
		user_name = request.getParameter("user_name");
		ti_member.put("user_name",user_name);
	}
	String s_user_class = "";
	if(request.getParameter("s_user_class")!=null && !request.getParameter("s_user_class").equals("")){
		s_user_class = request.getParameter("s_user_class");
		ti_member.put("user_class",s_user_class);
	}	
		
	
	String req_in_date2 = "";
	if(request.getParameter("req_in_date2")!=null && !request.getParameter("req_in_date2").equals("")){
		req_in_date2 = request.getParameter("req_in_date2");
		ti_member.put("cust_oper_date2",req_in_date2);
	}
	
	String s_area_attr = "";
	if(request.getParameter("area_attr")!=null && !request.getParameter("area_attr").equals("")){
		s_area_attr = request.getParameter("area_attr");
		ti_member.put("area_attr",s_area_attr);
		}
	Ti_custlevelInfo custlevelinfo = new Ti_custlevelInfo(); 
   
	
	
    ti_member.put("cust_type","0");	
	ti_member.put("m_state","1");	
	Ti_memberInfo ti_memberInfo = new Ti_memberInfo();
	Map custclassinfoMap = new Hashtable();
	Ts_custclassInfo custclassinfo = new Ts_custclassInfo();
	custclassinfoMap.put("class_type","0");
	String custclass_select =  custclassinfo.getSelectString(custclassinfoMap,"");
	
	String iStart = "0";
	int limit = 20;
	int counter = 0;
	Tb_commparaInfo tb_commparaInfo = new Tb_commparaInfo(); 
	String state = tb_commparaInfo.getSelectItem("39","");     
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
	List list = ti_memberInfo.getListByPageCom(ti_member,Integer.parseInt(iStart),limit);
	if (user_name.equals(""))	counter = ti_memberInfo.getCountByObjCom(ti_member);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?s_user_class="+s_user_class+"&req_in_date2="+req_in_date2+"&area_attr="+s_area_attr+"&s_cust_name="+s_cust_name+"&iStart=",Integer.parseInt(iStart),limit);
   
    Ts_areaInfo ts_areaInfo = new Ts_areaInfo();
	Map areaMap  = ts_areaInfo.getAreaClass();
	%>
<html>
  <head>
    
    <title>会员管理</title>
	<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
	<script language="javascript" type="text/javascript" src="/program/plugins/calendar/WdatePicker.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/engine.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/util.js"></script>
	<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/interface/Ts_areaInfo.js"></script>	
	<script type="text/javascript" src="js_commen.js"></script>
	<script type="text/javascript" src="/js/commen.js"></script>
	
	<script>	  setstartProvince('');	  </script>
</head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="80%">
				<h1>企业会员管理</h1>
			</td>
			<td>
			    <a href="addCompanyInfo.jsp"><img src="/program/admin/index/images/post.gif" /></a>
			</td>
		</tr>
	</table>
	
	<form action="index.jsp" name="indexForm" method="post">
	
	<!--
	<table width="100%" align="center" cellpadding="0" cellspacing="0" class="dl_so">
        <tr>
          <td width="9%" align="center"><img src="/program/admin/index/images/ban_01.gif" /></td>
          <td width="91%" align="left">
		  <h4>-----------------</h4>
		  <span>1----------------。</span><br/>
		  <span>2----------------。</span>
		  </td>
        </tr>
      </table>
      <br/>
	  -->
	  
	<table width="100%" cellpadding="0" cellspacing="0" class="dl_su">
		<tr>
			<td align="left" >
					按会员名称:<input name="s_cust_name" type="text" />
				
				 按登录帐号:<input name="user_name" type="text" />
				

         按所在地区:			

				<select name="province" id="province" onclick="setCitys(this.value)">
				  <option value="">省份</option> 
				</select>
				<select name="eparchy_code" id="eparchy_code" onclick="setAreas(this.value)">
				  <option value="">地级市</option> 
				 </select>
				<select name="city_code" id="city_code" style="display:inline" >
				 <option value="">市、县级市、县</option> 
				</select>
					<input type="hidden" name="area_attr_bak" id="area_attr_bak" value="" />
					<input type="hidden" name="area_attr" id="area_attr" value="" />
					
				<br>
			    按注册时间:<input name="req_in_date1" type="text" id="req_in_date1" class="Wdate" value="" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'req_in_date2\',{d:-1})}',readOnly:true})" size="15"  width="150px"/>
								~
							 <input name="req_in_date2" id="req_in_date2" type="text" class="Wdate" value="" onclick="WdatePicker({minDate:'#F{$dp.$D(\'req_in_date1\',{d:1})}',readOnly:true})" size="15" width="150px"/>
				按会员等级:<select name="s_user_class" >
									<option value="">请选择</option>
									<%=custclass_select%>
									</select>			
				<input name="searchInfo" type="button" value="查询" onclick="searcher();"/>	
			</td>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<% 
		int listsize = 0;
		if(list!=null && list.size()>0){
			listsize = list.size();
	%>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<select name="up_operating" id="up_operating" onchange="changeTime()">
				  	<option value="">请选择...</option>	
					<option value="-">删除</option>	
					<option value="c">启用</option>
					<option value="d">禁用</option>
				  	<%=state%>
				</select>	
				<div id="b_g" style="display:none">
				开始时间:<input type="text" name="s_start_date" id="s_start_date" class="Wdate" value="" onclick="WdatePicker({maxDate:'#F{$dp.$D(\'s_end_date\',{d:-1})}',readOnly:true})" size="15"  width="150px" />
				结束时间:<input type="text" name="s_end_date" id="s_end_date" class="Wdate" value="" onclick="WdatePicker({minDate:'#F{$dp.$D(\'s_start_date\',{d:1})}',readOnly:true})" size="15" width="150px" />
				</div>
				<input type="button" name="delInfo" onclick="operateInfo('up')" value="确定"  class="buttab" />
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
			<th width="5%" align="center"><input type="checkbox" name="checkall" id="checkall" onclick="selectAll()"></th>
			
		  	<th>会员名称</th>
		  	
		  	<th>会员所在地</th>
		  	
		  	<th>会员等级</th>
		  	
		  	<th>注册时间</th>
			
	  		<th width="20%">操作</th>
		</tr>
		
		
		<% 
		  		for(int i=0;i<list.size();i++){
		  			Hashtable map = (Hashtable)list.get(i);
		  			String cust_id="",cust_name="",cust_type="",area_attr="",state_code="",user_class="",reg_date="";
					String cust_class_name="",e="",f="",g="",by1="";
		  			  	if(map.get("cust_id")!=null) cust_id = map.get("cust_id").toString();
						if(map.get("cust_name")!=null) cust_name = map.get("cust_name").toString();
						if(map.get("cust_type")!=null) cust_type = map.get("cust_type").toString();
						if(map.get("area_attr")!=null) area_attr = map.get("area_attr").toString();
						if(map.get("state_code")!=null) state_code = map.get("state_code").toString();
						if(map.get("user_class")!=null) user_class = map.get("user_class").toString();
						if(map.get("reg_date")!=null) reg_date = map.get("reg_date").toString();
						
					 
						cust_class_name = custclassinfo.getcust_class_name(user_class);
						 
						if (custlevelinfo.checkCustLevel(cust_id).equals("1")) cust_class_name = cust_class_name+"<font style=color:red>[ 已过期 ]</font>";
						
						if(map.get("by1")!=null) by1 = map.get("by1").toString();
						if(reg_date.length()>10)reg_date=reg_date.substring(0,10);
						
						StringBuffer stateoutput =new StringBuffer();
						if(!area_attr.equals(""))
							{
							  String chIds[] =	area_attr.split("\\|");	
							  for(String chId:chIds)
							  {
								 if(areaMap!=null)
								 {
									 if(areaMap.get(chId)!=null)
									 {
										stateoutput.append("<a href='index.jsp?area_attr="+chId+"'>"+areaMap.get(chId).toString()+"</a> ");                 
									  }                  
								 
								  }                 
							   }		    
							}
						if(map.get("e")!=null) e = map.get("e").toString();
						if(map.get("f")!=null) f = map.get("f").toString();
						if(map.get("g")!=null) g = map.get("g").toString();
						
					//a：未审核 b：审核未通过 c：正常/审核通过 d：禁用
			
					
					String cust_type_string = "企业";
					String updatePage = "updateCompanyInfo.jsp";
					if(cust_type.equals("1")){
						cust_type_string="个人";
						updatePage = "updatePersonalInfo.jsp";
					}
	
					
		  %>
		
		<tr>
			<td width="5%" align="center"><input type="checkbox" name="checkone<%=i %>" id="checkone<%=i %>" value="<%=cust_id %>" /></td>
			
		  <td><a href="<%=updatePage%>?cust_id=<%=cust_id %>" class="infotitle"><%=cust_name%></a>
		  <div style="margin-top:8px;"></div>
	            <span class="<%if(state_code.indexOf("c")>-1)out.print("blueon"); else out.print("blueoff");%>">启用</span> 
	            <span class="<%if(state_code.indexOf("d")>-1)out.print("blueon"); else out.print("blueoff");%>">禁用</span> 
	            <span class="<%if(!e.equals(""))out.print("blueon"); else out.print("blueoff");%>">推荐</span>
	            <span class="<%if(!f.equals(""))out.print("blueon"); else out.print("blueoff");%>">置顶</span>
	            <span class="<%if(!g.equals(""))out.print("blueon"); else out.print("blueoff");%>">头条</span> 	
	   <br>
		  </td>
		  	
			<td><%=stateoutput%></td>
			<!--
		  	<td><a href="index.jsp?s_cust_type=<%=cust_type%>"><%=cust_type_string%></a></td>
		  	-->
		   
		  	
		  	<td><%=cust_class_name%> 
		  	<%
		  		if (user_class.equals("9"))
		  		{
		  	%>
		  	 密码：[ <%=by1%> ]
		  	<%
		  		}
		  		
		  	%>	
		  	</td>
		  	
		  	<td><%=reg_date%></td>
			<td width="10%">

			<a href="<%=updatePage%>?cust_id=<%=cust_id %>">修改信息</a> 			
			| <a href="updatePassWord.jsp?cust_id=<%=cust_id %>">修改密码</a>			
	  	|	<a href="javascript:deleteOneInfo('<%=cust_id%>','5779');">删除</a>	  		 
	  			<div id="backMessage<%=i %>"></div>
	  		</td>
			
			
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">

			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	
	  <input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
	  <input type="hidden" name="pkid" id="pkid" value="" />
	  <input type="hidden" name="bpm_id" id="bpm_id" value="5779" />
	  </form>
</body>

</html>
